package com.itheima.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

//@Component
//@Aspect
@Slf4j
public class TimeAspect {
    @Pointcut


    @Around("execution(* com.itheima.service.*.*(..))")
    public Object recordTime(ProceedingJoinPoint pj) throws Throwable {
        long begin = System.currentTimeMillis();
        Object proceed = pj.proceed();
        long end = System.currentTimeMillis();
        log.info(pj.getSignature()+"执行耗时"+(end-begin)+"ms");
        return proceed;
    }
}
